  # set project's name
  #PROJECT( Damage_To_Paintjob )

  cmake_minimum_required(VERSION 2.4.0)

  find_package(Qt4 REQUIRED) # find and setup Qt4 for this project
  
  #set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Ogre/CMake")
  #find_package(OGRE REQUIRED)  ## we cannot do this, since the debug dll is 305MB big and that crashes the QtCreator... 
								## so we have to stick to release and have to to the following SETs

  
  SET( SDL_LIBRARIES
       ${CMAKE_CURRENT_SOURCE_DIR}/../SDL/lib/libSDL.dll.a
	   ${CMAKE_CURRENT_SOURCE_DIR}/../SDL/lib/libSDLmain.a
  )

  SET( OGRE_LIBRARIES
	   ${CMAKE_CURRENT_SOURCE_DIR}/../OGRE/lib/release/libOgreMain.dll.a
  )
  SET( OGRE_INCLUDE_DIRS 
	   ${CMAKE_CURRENT_SOURCE_DIR}/../OGRE/include/OGRE/ 
  ) 
  
  if(CMAKE_BUILD_TYPE STREQUAL Debug)
	  SET( BULLET_LIBRARIES
		   ${CMAKE_BINARY_DIR}/libBulletDynamics_Debug.a
		   ${CMAKE_BINARY_DIR}/libBulletCollision_Debug.a
		   ${CMAKE_BINARY_DIR}/libLinearMath_Debug.a
	  )	
  else()
	  SET( BULLET_LIBRARIES
		   ${CMAKE_BINARY_DIR}/libBulletDynamics.a
		   ${CMAKE_BINARY_DIR}/libBulletCollision.a
		   ${CMAKE_BINARY_DIR}/libLinearMath.a
	  )	
  endif()
  
  SET( BULLET_INCLUDE_DIRS 
	   ${CMAKE_CURRENT_SOURCE_DIR}/../bullet/src/ 
  ) 
   
      
  # with SET() command you can change variables or define new ones
  # here we define SAMPLE_SRCS variable that contains a list of all .cpp files
  # note that we don't need \ at the end of line
  SET( dtp_SRCS
       ./src/main.cpp
       ./src/CCreateWorld.cpp
       ./src/ErrorOutputs.cpp
       ./GUI/configdialog.cpp
       ./GUI/GUILaborer.cpp
       ./GUI/mainwindow.cpp
       ./GUI/QLineEditEx.cpp
       ./Network/CClient.cpp
       ./Network/CServer.cpp
       ./Network/ZoidStuff/CClient_ZoidCom.cpp
       ./Network/ZoidStuff/CServer_ZoidCom.cpp
       ./Network/ZoidStuff/CLobbyRadio_ZoidCom.cpp
       ./Network/ZoidStuff/CBaseObject_ZoidCom.cpp
       ./Graphics/CGraphicEngine.cpp
       ./Graphics/CInputFrameListener.cpp
       ./Input/CSDLInputHandler.cpp
       ./Objects/CBaseObject.cpp
       ./Objects/CLivingObject.cpp
       ./Objects/CLightObject.cpp
       ./Objects/CTemporaryObjects.cpp
	   ./Physics/CPhysicsMain.cpp
  )

  SET( dtp_HDRS
       ./src/CCreateWorld.h
       ./src/ErrorOutputs.h
       ./src/DataConvertion.h
       ./Network/CClient.h
       ./Network/CServer.h
       ./Network/IServerCallbacks.h
       ./Network/IClientCallbacks.h
       ./Network/ZoidStuff/CClient_ZoidCom.h
       ./Network/ZoidStuff/CServer_ZoidCom.h
       ./Network/ZoidStuff/CBaseObject_ZoidCom.h
       ./Network/ZoidStuff/CLobbyRadio_ZoidCom.h
       ./Graphics/CGraphicEngine.h
       ./Graphics/CInputFrameListener.h
       ./Graphics/ConfigStructs.h
       ./Input/CSDLInputHandler.h
       ./Objects/CBaseObject.h
       ./Objects/CLivingObject.h 
       ./Objects/CTemporaryObjects.h 
       ./Objects/CLightObject.h 
       ./Objects/CObjects.h 
       ./Physics/CPhysicsMain.h
   )

  # another list, this time it includes all header files that should be treated with moc
  SET( dtp_MOC_HDRS
       ./GUI/configdialog.h
       ./GUI/mainwindow.h
       ./GUI/QLineEditEx.h   
	   ./Network/CServer.h
       ./Network/CClient.h
  )
  
  # some .ui files
  SET( dtp_UIS
       ./GUI/configdialog.ui
       ./GUI/mainwindow.ui
  )
  
  # and finally an resource file
  SET( dtp_RCS
       ./src/dtp_mainres.qrc
  )
	
  # enable warnings
  ADD_DEFINITIONS( -Wall )
  
  # by default only QtCore and QtGui modules are enabled
  # other modules must be enabled like this:
  SET( QT_USE_QT3SUPPORT TRUE )   
  SET( QT_USE_QTXML TRUE )
  
  # this command finds Qt4 libraries and sets all required variables
  # note that it's Qt4, not QT4 or qt4
  FIND_PACKAGE( Qt4 REQUIRED )
  
  # add some useful macros and variables
  # (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script)
  INCLUDE( ${QT_USE_FILE} )
  
  # this command will generate rules that will run rcc on all files from SAMPLE_RCS
  # in result SAMPLE_RC_SRCS variable will contain paths to files produced by rcc
  QT4_ADD_RESOURCES( dtp_RC_SRCS ${dtp_RCS} )
  
  # this will run uic on .ui files:
  QT4_WRAP_UI( dtp_UI_HDRS ${dtp_UIS} )
  
  # and finally this will run moc:
  QT4_WRAP_CPP( dtp_MOC_SRCS ${dtp_MOC_HDRS} )
  
  # we need this to be able to include headers produced by uic in our code
  # (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
  INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OGRE_INCLUDE_DIRS} "${CMAKE_SOURCE_DIR}/Ogre/boost_1_44" ${BULLET_INCLUDE_DIRS})
  
  # here we instruct CMake to build "sample" executable from all of the source files
  ADD_EXECUTABLE( Damage_To_Paintjob ${dtp_SRCS} ${dtp_MOC_SRCS} ${dtp_RC_SRCS} ${dtp_UI_HDRS} ${dtp_HDRS} )
  
  # last thing we have to do is to tell CMake what libraries our executable needs,
  # luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us:
  TARGET_LINK_LIBRARIES( Damage_To_Paintjob ${QT_LIBRARIES} ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${SDL_LIBRARIES} ${BULLET_LIBRARIES})

  # add zoidcom (for networking)
  if(CMAKE_BUILD_TYPE STREQUAL Debug)
	TARGET_LINK_LIBRARIES( Damage_To_Paintjob ${CMAKE_CURRENT_SOURCE_DIR}/../zoidcom/lib/mingw/libzoidcom_mwd.a)
  else()
  	TARGET_LINK_LIBRARIES( Damage_To_Paintjob ${CMAKE_CURRENT_SOURCE_DIR}/../zoidcom/lib/mingw/libzoidcom_mw.a)
  endif()
